/**
 * Created by Junchuan.Wu on 2015/11/22 0022.
 */
window.onload = function () {
    /**
     * drag_drop.js
     */
    /*添加监听*/
    var cols = document.querySelectorAll('.column');
    [].forEach.call(cols, function (col) {
        col.addEventListener('dragstart', handleDragStar, false);
        col.addEventListener('dragenter', handleDragEnter, false);
        col.addEventListener('dragleave', handleDragLeave, false);
        col.addEventListener('drop', handleDrop, false);
        col.addEventListener('dragend', handleDragEnd, false);
    });
    /*dragend*/

    function handleDragEnd(e) {
        [].forEach.call(cols, function (col) {
            col.classList.remove('over');
        });
    }

    /**
     * clock.js
     */
    canvas = document.getElementById("myclock");
    ctx = canvas.getContext("2d");
    radgrad = ctx.createRadialGradient(150, 150, 300, 150, 150, 110);
    radgrad.addColorStop(0, '#000');
    radgrad.addColorStop(1, '#FFF');
    radgrad2 = ctx.createRadialGradient(150, 150, 300, 150, 150, 110);
    radgrad2.addColorStop(0, "#000");
    radgrad2.addColorStop(.83, "rgb(255,255,100)");
    radgrad2.addColorStop(1, "rgb(255,255,100)");
    drawFrame();
    /**
     * webSql
     */
    username = document.getElementById('username');
    password = document.getElementById('password');
    favorite = document.getElementById('favorite');
    login_username = document.getElementById('login_username');
    login_password = document.getElementById('login_password');
    show_username = document.getElementById('show_username');
    show_password = document.getElementById('show_password');
    show_favorite = document.getElementById('show_favorite');
    input_username = document.getElementById('input_username');
    if(window.openDatabase===undefined) {
        alert("您的浏览器不支持本地存您的浏览器不支持webSQL Database API。");
    }else{
        db = openDatabase('wujunchuan','99.99','wujunchuan',1000);
        db.transaction(function (tx) {
            tx.executeSql('CREATE TABLE IF NOT EXISTS my_users(username,password,favorite)');
        });
    }
};